package com.fxm.controller;

import com.fxm.domain.User;
import com.fxm.returns.RespCode;
import com.fxm.returns.RespEntity;
import com.fxm.service.UserService;
import com.fxm.vo.param.IntegralParam;
import com.fxm.vo.param.OpenParam;
import com.fxm.vo.param.UserParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

/**
 * <p>
 * 用户信息接口 前端控制器
 * </p>
 *
 * @author fxm
 * @since 2020-12-30
 */
@RestController
@RequestMapping("/user")
@Slf4j
@Api(value = "用户信息接口", tags = "用户信息接口")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/info")
    @ApiOperation(value = "查询用户信息")
    public RespEntity getUserInfo(@RequestBody OpenParam openParam) {
        RespEntity<User> respEntity = userService.getUserByOpenId(openParam);
        return respEntity;
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改用户积分")
    public RespEntity updateUserIntegral(@RequestBody IntegralParam integralParam) {
        RespEntity respEntity = userService.updateUser(integralParam);
        return respEntity;
    }
}
